class Solution {
    public static int maxProfit(int[] prices) {

        int maxFit = 0;

        for (int i = 0; i < prices.length; i++) {
            //得到当天价格
            int price = prices[i];
            // 找后面天数最大值
            int maxPrice = price;
            for (int j = i + 1; j < prices.length; j++) {
                int price1 = prices[j];
                if (price1 > maxPrice) {
                    maxPrice = price1;
                }
            }
            int i1 = maxPrice - price;
            // 找到最大差值
            if (i1 > maxFit) {
                maxFit = i1;
            }
        }
        return maxFit;
    }
}